#include <QCoreApplication>
#include "vpprotocollib.h"
#include <windows.h>
#include <iostream>

static void test_cb(void *param, unsigned int len)
{
   std::cout << "testcb be call!" << std::endl;
}

static void test_cb1(void *param, unsigned int len)
{
   unsigned char *pdata = (unsigned char *)param;
   int i;

   for(i = 0; i < len; i++)
   {
       printf("0x%02x ", pdata[i]);
   }
   std::cout << std::endl;
   std::cout << "testcb1 be call!" << std::endl;
}

int main(int argc, char *argv[])
{
    unsigned char test_buf[] = "\xAA\x02\x9F\x80\xB7\x55\xAA\x04\x9F\x01\x02\x03\x31"; // TEST BUFFER
    sMsgType_t msg = {.m_cmdType = 0x9f, .m_cmdID = 0x80, .m_cb = test_cb};
    sMsgType_t msg2 = {.m_cmdType = 0x9f, .m_cmdID = 0x01, .m_cb = test_cb1};

    Protocol_Init();
    Protocol_RegisterCmdCB(&msg);
    Protocol_RegisterCmdCB(&msg2);

    std::cout << Protocol_GetVersion() << std::endl;

    while(true)
    {
        Protocol_SetPacket(test_buf, sizeof(test_buf));
        Sleep(1000);
    }
    return 0;
}
